<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("fnId", request.getAttribute("fnId"));
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer"));
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
<style>
	.btns{
		display:inline-block;
		margin:5px 0;
		width: 100%;
	}
</style>
</head>
<body class="gray-bg">
	<nav class="huiNav">
		<i class="fa fa-home"></i> 首页 <span>&gt;</span>个人中心<span>&gt;</span>导师中心
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>

	<div class="ibox-content">
	<!-- 搜索框部分start -->
	<p:btn value="serch">
		<form class="form-inline" id="serchform">
		<div class="form-group mr-20">
			<label for="exampleInputName2">学生名称</label> 
			<input name="name" type="text" class="form-control">
		</div>
			<button  onclick="myGrid.serchData()" type="button" class="btn btn-info btn-sm"><i class="fa fa-search " ></i> 搜索</button>
			<button  type="button" onclick="MForm.reset('#serchform');" class="btn btn-info btn-sm"><i class="fa fa-refresh " ></i> 重置</button>
		</form>
		</p:btn>
	<!-- 搜索框部分en -->
		<div class="option-bar" >
		<p:btn value="dels">
			<button onclick="myGrid.delItems()" type="button" class="btn btn-danger btn-sm"><i class="fa fa-trash" ></i>批量删除</button>
		</p:btn>
		<p:btn value="add">
			<button onclick="openAdd()" type="button" class="btn btn-success btn-sm"><i class="fa fa-plus" ></i>  新增</button>
		</p:btn>
		</div>
		<table id="mgrid" >
			<thead>
				<tr>
					<th data-formatter="MGrid.indexfn" data-align="center"  data-width="30px" >序号</th>
					<th data-field="name" >学生名称</th>
					<th data-align="center"  data-width="150px" data-field="id" data-formatter="buidOperate">操作</th>
				</tr>
			</thead>
		</table>
	</div>
	
	<script type="text/javascript">
	
	var myGrid;
		$(function(){
			//有删除权限
			var delUrl="";
			<p:btn value="dels">
			delUrl="${path}/admin/project/del";
			</p:btn>
			
			 myGrid=MGrid.initGrid({
				 url:"${path}/admin/newAssessment/showList",
				 delUrl:delUrl
			 });
		});
		function buidOperate(value, row, index){
			console.log(row.taskExecutionList[0]);
			var html='';
			for(var i=0;i<row.taskExecutionList.length;i++){
				if(row.taskExecutionList[i].taskName=='框架教学'){
					if(row.taskExecutionList[i].status=='1'){
						html+='<button class="btn btn-success" id="btns1 btns" onclick="frameTeaching2('+value+')"> 结束框架教学</button>'
					}else{
						html+='<button class="btn btn-success btns" disabled> 框架教学已结束</button>'
					}
				}
				if(row.taskExecutionList[i].taskName=='撰写周报'){
					if(row.taskExecutionList[i].status=='1'){
						html+='<button class="btn btn-success btns" id="btns2" onclick="weeklyReport2('+value+')"> 查看周报</button>'
					}else{
						html+='<button class="btn btn-success btns" disabled> 查看周报已结束</button>'
					}
				}
				if(row.taskExecutionList[i].taskName=='环境搭建'){
					if(row.taskExecutionList[i].status=='1'){
						html+='<button class="btn btn-success btns" id="btns3" onclick="environmentBuilding2('+value+')"> 查看环境搭建 </button>'
					}else{
						html+='<button class="btn btn-success btns" disabled>环境搭建已结束</button>'
					}
				}
				if(row.taskExecutionList[i].taskName=='框架解惑'){
					if(row.taskExecutionList[i].status=='1'){
						html+='<button class="btn btn-success btns" id="btns3" onclick="frameDisabuse2('+value+')">框架解惑 </button>'
					}else{
						html+='<button class="btn btn-success btns" disabled>框架解惑已结束</button>'
					}
				}
				if(row.taskExecutionList[i].taskName=='项目总结'){
					if(row.taskExecutionList[i].status=='1'){
						html+='<button class="btn btn-success btns" id="btns3" onclick="workPractice2('+value+')">查看项目总结 </button>'
					}else{
						html+='<button class="btn btn-success btns" disabled>项目总结已结束</button>'
					}
				}
				if(row.taskExecutionList[i].taskName=='导师评分'){
					if(row.taskExecutionList[i].status=='1'){
						html+='<button class="btn btn-success btns" id="btns3" onclick="tutorScore2('+value+')">导师评分 </button>'
					}else{
						html+='<button class="btn btn-success btns" onclick="modifyAssess('+value+')">修改评价</button>'
					}
				}
			}
			html+=''
			return html; 
		}
		/**
		*导师结束框架教学任务 
		*/
		function frameTeaching2(id){
			layer.confirm("确认结束任务？",function(){
		        $.AjaxProxy().invoke("${path}/admin/taskExecution/endTask?key="+id,function(loj){
		        	if(loj.getValue("status") == 'ok'){
						layer.alert(loj.getValue("info"), {
							icon : 1
						}, function(inindex) {
							// 关闭提示层
							layer.close(inindex);
							layer.close();
							location.reload();
						});
					}else{
						layer.alert(loj.getValue("info"), {
							icon : 5
						}, function(inindex) {
							// 关闭提示层
							layer.close(inindex);
						});
					}
		        });
			});
		}
		
		/**
		*导师结束撰写周报任务 
		*/
		function weeklyReport2(id){
			layer.confirm("确认结束任务？",function(){
		        $.AjaxProxy().invoke("${path}/admin/taskExecution/endWeeklyTask?key="+id,function(loj){
		        	if(loj.getValue("status") == 'ok'){
						layer.alert(loj.getValue("info"), {
							icon : 1
						}, function(inindex) {
							// 关闭提示层
							layer.close(inindex);
							layer.close();
							location.reload();
						});
					}else{
						layer.alert(loj.getValue("info"), {
							icon : 5
						}, function(inindex) {
							// 关闭提示层
							layer.close(inindex);
						});
					}
		        });
			});
		}
		/**
		*环境搭建 
		*/
		function environmentBuilding2(id) {
			layer.full(layer.open({
				type : 2,
				title : "环境搭建截图",
				area : [ MUI.SIZE_L, '400px' ],
				maxmin : true,
				content : [ '${path}/admin/taskExecution/editEnvironment?id=' + id]
			}));
		}
		
		/**
		*导师结束框架解惑任务 
		*/
		function frameDisabuse2(id){
			layer.confirm("确认结束任务？",function(){
		        $.AjaxProxy().invoke("${path}/admin/taskExecution/endFrameDisabuse?key="+id,function(loj){
		        	if(loj.getValue("status") == 'ok'){
						layer.alert(loj.getValue("info"), {
							icon : 1
						}, function(inindex) {
							// 关闭提示层
							layer.close(inindex);
							layer.close();
							location.reload();
						});
					}else{
						layer.alert(loj.getValue("info"), {
							icon : 5
						}, function(inindex) {
							// 关闭提示层
							layer.close(inindex);
						});
					}
		        });
			});
		}
		
		/**
		*项目总结  
		*/
		function workPractice2(id) {
			layer.full(layer.open({
				type : 2,
				title : "项目总结",
				area : [ MUI.SIZE_L, '400px' ],
				maxmin : true,
				content : [ '${path}/admin/taskExecution/editWorkPractice?id=' + id]
			}));
		}
		/**
		*导师评分  
		*/
		function tutorScore2(id) {
			layer.full(layer.open({
				type : 2,
				title : "导师评分",
				area : [ MUI.SIZE_L, '400px' ],
				maxmin : true,
				content : [ '${path}/admin/taskExecution/editTutorScore?id=' + id]
			}));
		}
		/**
		*导师评分  
		*/
		function modifyAssess(id) {
			layer.full(layer.open({
				type : 2,
				title : "修改导师评价",
				area : [ MUI.SIZE_L, '400px' ],
				maxmin : true,
				content : [ '${path}/admin/taskExecution/editModifyAssess?id=' + id]
			}));
		}
		
	</script>
</body>
</html>
